import numpy as np
import matplotlib.pyplot as plt
import os

fname = 'fig3g.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
n = data['n']
D = data['D']
delta_R = data['delta_R']
R1 = data['R60mT'] # Rxy at B=60mT
R2 = data['Rm60mT'] # Rxy at B=-60mT
n0 = data['n0'] # density at charge neutrality point
D0 = data['D0'] 
ns = data['ns'] # density at 4 electron per moire unit cell
device_name = data['device_name']
B = data['B']
T = data['T']
back_gate_thickness_nm = data['back_gate_thickness_nm']
top_gate_thickness_nm = data['top_gate_thickness_nm']

# plot
fig, ax = plt.subplots(1, 1, figsize=(6, 4))
scatter = ax.scatter(n, D, c=delta_R/1e3, marker='s', s=1, cmap='viridis_r', vmin=-0.4, vmax=0.1)
ax.set_xlabel('Density ($10^{12}$ cm$^{-2}$)')
ax.set_ylabel('$D/\epsilon_0$ (V/nm)')
ax.set_title('Fig. 3g')
plt.colorbar(scatter, label='$\Delta R_{xy}$ ($k\Omega$)')
plt.show()